package com.osmap.openstreetmap.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ys.peng
 * Date: 14-1-21
 * Time: 下午3:57
 * To change this template use File | Settings | File Templates.
 */
public class NewsAdAdapter extends PagerAdapter {
    private List<View> pageView;
    private Context context;
//    private List<NewsBean> wheel;

    public NewsAdAdapter(List<View> pageView, Context context) {
        this.pageView = pageView;
        this.context = context;
//        this.wheel = wheel;
    }

    @Override
    public int getCount() {
        return pageView.size();  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(pageView.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = pageView.get(position);
//        initListener(view, position);
        container.addView(view);
        return view;    //To change body of overridden methods use File | Settings | File Templates.
    }

//    public void initListener(View view, final int i) {
//        view.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Intent intent = new Intent(context, NewsDetailActivity.class);
//                intent.putExtra("newsId", wheel.get(i).getNewsId());
//                intent.putExtra("newsTitle", wheel.get(i).getMainTitle());
//                context.startActivity(intent);
//            }
//        });
//    }
}
